package com.fang.fen.blog.apigateway;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;

public class Test {

    public static void main(String[] args) {
        String path = "";
        try {

            RandomAccessFile raf = new RandomAccessFile("C:\\Users\\fang_\\Desktop\\新建文本文档 (2).txt", "rw");
            FileChannel fc = raf.getChannel();
            BufferedReader br = new BufferedReader(Channels.newReader(fc, "utf-8"));
            String line;
            BigDecimal total = new BigDecimal(0l);
            while( (line = br.readLine())!= null) {
                total = total.add(new BigDecimal(line));
            }
            System.out.println(total);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
